package pkg

import (
	"fmt"
	"github.com/go-ini/ini"
)

type app struct {
	Port string
}

type databases struct {
	Host         string
	User         string
	Password     string
	Dbname       string
	MaxIdleConns int
	MaxOpenConns int
	Prefix       string
}

var AppConf = &app{}
var DatabasesConf = &databases{}

//获取配置文件，初始化配置
func ConfInit() {
	load, err := ini.Load("./config/env.ini")
	if err != nil {
		fmt.Errorf("err %v", err)
	}
	port := load.Section("app").Key("port").String()
	load.Section("databases").MapTo(DatabasesConf)
	AppConf.Port = port
}
